<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="__PUBLIC__/addons-install.css">
    <script src="__PUBLIC__/jquery2.0.0.min.js"></script>
</head>
<body>
<div class="container">
    <div class="container-head">
        后台安装程序
    </div>
    <div class="container-form">
        <form action="">
            <div class="form-head">
                <h1>数据库设置</h1>
            </div>
            <div class="form-item">
                <label>数据库IP</label>
                <div class="form-input">
                    <input type="text" name="db[host]" value="{$config.db.host}"/>
                </div>
            </div>
            <div class="form-item">
                <label>数据库名</label>
                <div class="form-input">
                    <input type="text" name="db[name]" value="{$config.db.name}"/>
                </div>
            </div>
            <div class="form-item">
                <label>用户名</label>
                <div class="form-input">
                    <input type="text" name="db[user]" value="{$config.db.user}"/>
                </div>
            </div>
            <div class="form-item">
                <label>密码</label>
                <div class="form-input">
                    <input type="text" name="db[pass]" value="{$config.db.pass}"/>
                </div>
            </div>
            <div class="form-item">
                <label>端口</label>
                <div class="form-input">
                    <input type="text" name="db[port]" value="{$config.db.port}"/>
                </div>
            </div>
            <div class="form-item">
                <label>表前缀</label>
                <div class="form-input">
                    <input type="text" name="db[prefix]" value="{$config.db.prefix}"/>
                </div>
            </div>
            <div class="form-head">
                <h1>管理员设置</h1>
            </div>
            <div class="form-item">
                <label>用户名</label>
                <div class="form-input">
                    <input type="text" name="admin[account]" value="{$config.admin.account}"/>
                </div>
            </div>
            <div class="form-item">
                <label>用户名</label>
                <div class="form-input">
                    <input type="text" name="admin[pass]" value="{$config.admin.pass}"/>
                </div>
            </div>
            <div class="form-item">
                <button type="button" class="form-btn">确定安装</button>
            </div>
        </form>
    </div>
</div>
<script>
    $('.form-btn').click(function(){
        let button = $(this);
        button.attr('disabled' , true);
        $.ajax({
            url : '/admin/app/modules-index/index' ,
            type : 'POST' ,
            data : $('form').serialize() ,
            dataType : 'json' ,
            success : function(res){
                button.attr('disabled' , false);
                if (res.code == 200){
                    alert('安装成功，请及时删除安装模块数据');
                    window.location.reload();
                }else{
                    alert('安装失败' + res.msg)
                }
            }
        })
    })
</script>
</body>
</html>